package me.jzn.alib.drawable;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RemoteViews;

import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;

import me.jzn.alib.utils.ResUtil;

public class ResDrawableType implements DrawableType {
    @DrawableRes
    private int resId;

    public ResDrawableType(@DrawableRes int res) {
        this.resId = res;
    }

    @DrawableRes
    public int getResId() {
        return resId;
    }

    @Override
    public Drawable getDrawable() {
        return ResUtil.getDrawable(resId);
    }

    @Override
    public void setImageView(ImageView iv) {
        iv.setImageResource(resId);
    }

    @Override
    public void setBackground(View view) {
        view.setBackgroundResource(resId);
    }

    @Override
    public void setRemoteViews(RemoteViews rv, @IdRes int imageViewId) {
        rv.setImageViewResource(imageViewId, resId);
    }
}
